//
//  HomePlayerRecommendationsSubView.m
//  gamebox_qpp
//
//  Created by 赵隆杰 on 2022/12/8.
//

#import "HomePlayerRecommendationsSubView.h"

@interface HomePlayerRecommendationsSubView ()

@property (weak, nonatomic) IBOutlet UIImageView *userHeadImage;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *levelLabel1;
@property (weak, nonatomic) IBOutlet UILabel *levelLabel2;
@property (weak, nonatomic) IBOutlet UITextView *commentTextView;
@property (weak, nonatomic) IBOutlet YYAnimatedImageView *gameIcon;
@property (weak, nonatomic) IBOutlet UILabel *gameNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *gameSubNameLabel;
@property (weak, nonatomic) IBOutlet UIView *signView;
@property (weak, nonatomic) IBOutlet UILabel *scoreLabel;
@property (weak, nonatomic) IBOutlet UILabel *typeLabel;

@property (weak, nonatomic) IBOutlet UIView *shadowView;

@end

@implementation HomePlayerRecommendationsSubView
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.shadowView.layer.shadowOffset = CGSizeMake(0,0);
    self.shadowView.layer.masksToBounds = NO;
    self.shadowView.layer.shadowOpacity = 1;
    self.shadowView.layer.shadowColor = [UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.10].CGColor;
    self.shadowView.layer.shadowRadius = 8;
}


- (void)setDetailModel:(GameDetailNewModel *)detailModel
{
    [self.userHeadImage yy_setImageWithURL:[NSURL URLWithString:[LocalData getHeadStr]] placeholder:[UIImage imageNamed:@"appicon"]];
    if ([LocalData getHeadStr]) {
        UIImage *image = [NSObject Base64StrToUIImage:[LocalData getHeadStr]];
        self.userHeadImage.image = image;
    } else {
        [self.userHeadImage setImage:[UIImage imageNamed:@"appicon"]];
    }
    
    self.nameLabel.text = @"abcabcabcabc";
    self.levelLabel1.text = @"12345678";
    self.levelLabel2.text = @"7654321";
    
    self.commentTextView.text = detailModel.gameIntroduce;
    
    [self.gameIcon yy_setImageWithURL:[NSURL URLWithString:detailModel.gameMainIcon] placeholder:placeholder_image];
    self.gameNameLabel.text = detailModel.gameName;
    self.gameSubNameLabel.text = [NSString stringWithFormat:@" %@  ", detailModel.gameSubName];
    
    [self.signView removeAllSubviews];
    UIView *temsignOneView = nil;
    NSInteger count = detailModel.gameSignArr.count;
    if (count > 3) count = 3;
    for (NSInteger i = 0; i < count; i++) {
        NSString *signStr = detailModel.gameSignArr[i];
        UIView *signOneView = [[UIView alloc] init];
        signOneView.backgroundColor = UIColorHex(0xEBEBEB);
        signOneView.layer.cornerRadius = 4;
        signOneView.layer.masksToBounds = YES;
        [self.signView addSubview:signOneView];
        UILabel *signLabel = [[UILabel alloc] init];
        signLabel.text = signStr;
        signLabel.font = [UIFont systemFontOfSize:12];
        signLabel.textColor = kColor888888;
        [signOneView addSubview:signLabel];
        [signOneView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.signView).offset(3);
            if (temsignOneView) {
                make.left.equalTo(temsignOneView.mas_right).offset(3);
            } else {
                make.left.equalTo(self.signView);
            }
        }];
        [signLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(signOneView);
            make.top.equalTo(signOneView).offset(2);
            make.left.equalTo(signOneView).offset(0);
        }];
        temsignOneView = signOneView;
    }
    
    self.scoreLabel.text = [NSString stringWithFormat:@"%@分", detailModel.gameScore];
    
    self.typeLabel.text = [detailModel.gameTypes componentsJoinedByString:@"|"];

    self.layer.cornerRadius = 6;
    self.layer.backgroundColor = [UIColor whiteColor].CGColor;
    self.layer.shadowColor = [UIColor whiteColor].CGColor;
    self.layer.shadowOffset = CGSizeMake(0,0);
    self.layer.shadowOpacity = 1;
    self.layer.shadowRadius = 15;
}

@end
